package com.ttuproject.ttu.service.serviceImpl;

import com.ttuproject.ttu.exception.Advice;
import com.ttuproject.ttu.exception.TTUException;
import com.ttuproject.ttu.mapper.TTUMapper.WaringMapper;
import com.ttuproject.ttu.service.WaringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName WaringServiceImpl
 * @Description TODO
 * @Author cw
 * @Date 2021/12/17 14:12
 */
@Service
public class WaringServiceImpl implements WaringService {

    @Autowired
    WaringMapper waringMapper;

    @Override
    public boolean insertWaring(String warNumber, String result) {
        if (warNumber.isEmpty() || result.isEmpty()) {
            throw new TTUException(Advice.INSERT_CANNOT_EMPTY);
        } else {
           boolean insertWaringType = waringMapper.insertWaring(warNumber, result);
            if (insertWaringType) {
                return true;
            } else {
                throw new TTUException(Advice.INSERT_WAR_ERROR);
            }
        }

    }
}
